/**
 * 
 */
package com.runningfox.humor;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.runningfox.model.Comment;

/**
 * @author lhy
 *
 */
public class CommentView extends LinearLayout {
	Comment node;
	LayoutInflater inf;
	Humor callback;
	Context c ;
	View view;
	TextView txtname,txtbody,txttime;
	public CommentView(Humor humor,Comment node) {
		super(humor.c);
		c=humor.c;
		callback=humor;
		// TODO Auto-generated constructor stub
//		node=commentnode;
		inf = LayoutInflater.from(c);
		view = inf.inflate(R.layout.commentnode, null);
		this.addView(view);
		txtname=(TextView) this.view.findViewById(R.id.CommentTextViewName);
		txtbody = (TextView)this.view.findViewById(R.id.CommentTextViewBody);		
		txttime =(TextView)this.view.findViewById(R.id.CommentTextViewTime);
		this.setNode(node);
	}
	public void setNode(Comment commentnode) {
		// TODO Auto-generated method stub
		this.node=commentnode;
//		txtname.setText("anynoumouse");
		txtname.setText(node.name);
		txtbody.setText(node.body);
		txttime.setText(node.dateStr);
//		txttime.setText(node.dateStr);
	}

	final static int bgSelected = Color.rgb(0x30, 0x30, 0x30);//#303030
	final static int bgNomal = Color.rgb(0x18, 0x18, 0x18);
	public void setSelect(boolean b){
		if(b){
			this.txtname.setTextColor(Color.WHITE);
			this.setBackgroundColor(bgSelected);
		}else{
			this.txtname.setTextColor(Color.WHITE);
			this.setBackgroundColor(bgNomal);
		}
	}
}
